package com.platform.server.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class ParamsValidator implements ConstraintValidator<ValidateObject, String> {

	@Override
	public void initialize(ValidateObject value) {
		//初始化
	}

	@Override
	public boolean isValid(String params,
			ConstraintValidatorContext paramConstraintValidatorContext) {
		if(params==null||"".equals(params)){
			return false;
		}
		//String regEx="([^<>#{}'\"@\\[\\]\\s]+)";
		String regEx="([`~!@#$%^&*()+=|{}':;',//[//].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]+)";
		Pattern p=Pattern.compile(regEx);
		Matcher m =p.matcher(params);
		
		if(m.find()){
			return false;
		}
		return true;
		
	}

}
